Skip to content

[FIX] OWFile: Report errors for incorrect file formats instead of crashing#1635

Merged
ajdapretnar merged 1 commit intobiolab:masterfrom
janezd:ofwile-catch-errors
Oct 7, 2016
Merged

[FIX] OWFile: Report errors for incorrect file formats instead of crashing#1635
ajdapretnar merged 1 commit intobiolab:masterfrom
janezd:ofwile-catch-errors

Conversation

@janezd
Copy link
Contributor

@janezd janezd commented Oct 6, 2016

If the file was in incorrect format, the exception was sometimes thrown already by FileFormat.get_reader. To see this, rename an arbitrary file to .xlsx and try to load it.

The code would be simpler with a single try-except. However, since it catches any exception, I prefer wrapping a single call, hence two separate try-except blocks.

@janezd janezd force-pushed the ofwile-catch-errors branch from e8bcb34 to a6c73ef Compare October 6, 2016 16:34
@janezd janezd changed the title OWFile: Catch errors in get_reader [FIX] OWFile: Report errors for incorrect file formats instead of crashing Oct 6, 2016
@codecov-io
Copy link

codecov-io commented Oct 6, 2016

Current coverage is 88.66% (diff: 100%)

Merging #1635 into master will not change coverage

@@             master      #1635   diff @@
==========================================
  Files            78         78          
  Lines          8124       8124          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
  Hits           7203       7203          
  Misses          921        921          
  Partials          0          0          

Sunburst

Powered by Codecov. Last update f539789...a6c73ef

@ajdapretnar ajdapretnar merged commit 314ecba into biolab:master Oct 7, 2016
Copy link
Contributor

@lanzagar lanzagar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has already been merged, so it is not possible to request changes in the review.
But can be fixed in a new PR.

self.editor_model.set_domain(None)
self.reader = self._get_reader()
if not self.reader:
self.data = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.data used to be cleared in case of errors, now it is not anymore...

This is used in reports for example (maybe elsewhere too), which now report on previous data, even after trying to open something else and failing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants